﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EkejiWeb.Model;
using EkejiWeb.BLL;
using System.Data;

namespace EkejiWeb.Web.Admin.AdminUser
{
    public partial class SelectDelete : System.Web.UI.Page
    {
        AdminModel model = new AdminModel();
        AdminBLL bll = new AdminBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }
        private void BindData()
        {
            DataSet ds = bll.GetAllList();
            PagedDataSource ps = new PagedDataSource();
            ps.DataSource = ds.Tables[0].DefaultView;
            ps.AllowPaging = true;
            AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;
            ps.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
            ps.PageSize = AspNetPager1.PageSize;
            rptUser.DataSource = ps;
            rptUser.DataBind();
        }
        protected void lbDelete_Command(object sender, CommandEventArgs e)
        {
            bool flag = false;
            int id = int.Parse(e.CommandName);
            flag = bll.Delete(id);
            if (flag)
            {
                Response.Write("<Script Language=JavaScript>alert('删除成功！');</Script>");
                BindData();
                return;
            }
            else
            {
                Response.Write("<Script Language=JavaScript>alert('删除失败！');</Script>");
                BindData();
                return;
            }
        }
        protected void AspNetPager1_PageChanged(object src, EventArgs e)
        {
            BindData();
        }
    }
}